﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace Nuane.Posterous
{

	/// <summary>
	/// Represents a posterous tag.
	/// </summary>
	public class PosterousTag
	{
		//<tag>
		//  <id>1</id>
		//  <tag_string>New York Food</tag_string>
		//  <count>500</count>
		//</tag>

		/// <summary>
		/// Gets the ID of this tag.
		/// </summary>
		/// <value>Tag ID.</value>
		public int Id { get; private set; }

		/// <summary>
		/// Gets the name of this tag (tag string).
		/// </summary>
		/// <value>Name (tag string).</value>
		public string Name { get; private set; }

		/// <summary>
		/// Gets the count of posts associated with this tag.
		/// </summary>
		/// <value>Tag count.</value>
		public int Count { get; private set; }

		internal PosterousTag(XmlNode tag)
		{
			if (tag.Name != "tag")
				throw new PosterousException("Invalid response.", PosterousExceptionStatus.ServerProtocolViolation);

			Id = Helper.ToInt32(Helper.GetChildElementValue(tag, "id"));
			Name = Helper.GetChildElementValue(tag, "tag_string");
			Count = Helper.ToInt32(Helper.GetChildElementValue(tag, "count"));
		}
	}
}
